import { getRandomString } from "@/utils/hashId";
import * as echarts from "echarts";
export default {
  data: () => {
    return {
      id: null,
      chart: null,
      dom: null,
      option: {
        grid: {
          left: "3%",
          right: "4%",
          top: "3%",
          bottom: "8%",
          containLabel: true
        }
      }
    };
  },
  created() {
    this.id = getRandomString(64);
  },
  methods: {
    created(option) {
      this.option = Object.assign(this.option, option);
      this.dom = document.getElementById(this.id);
      this.chart = echarts.init(this.dom);
      this.option && this.chart.setOption(this.option);
    }
  }
};
